package com.lfnyxy.common.eenum;

import com.lfnyxy.common.cnst.AppString;

/**
 * Created by ted on 17/9/11.
 * 操作结果通用类。定义所有可能出现的异常结果。
 */
public enum IntResultType {
    ONE(1, AppString.ONE),
    ZERO(0, AppString.ZERO),
    FAILED(0, AppString.OPERATE_FAILED),
    DUPLICATION(-1, AppString.DUPLICATE),
    UNKNOW(-999, AppString.UnKnow);

    IntResultType(int code, String content) {
        this.code = code;
        this.content = content;
    }

    private int code;
    private String content;

    public int getCode() {
        return code;
    }

    public String getContent() {
        return content;
    }

    public static IntResultType valueOf(int code){
        for(IntResultType item: values()){
            if(item.getCode() == code){
                return item;
            }
        }
        return UNKNOW;
    }
}
